﻿

#region Usings
using System;
using System.Security.Cryptography;
using Jenvin.Library.Utils.Encryption;
#endregion

namespace Jenvin.Library.Utils.Encryption
{
    /// <summary>
    /// SHA1 function hash
    /// </summary>
    public class SHA1Hash : IHash
    {
        #region Public Static Functions

        /// <summary>
        /// 使用sha1 计算 Hash 
        /// </summary>
        public string ComputeHash(string Input)
        {
            SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
            byte[] InputArray = System.Text.Encoding.ASCII.GetBytes(Input);
            byte[] HashedArray = SHA1.ComputeHash(InputArray);
            SHA1.Clear();
            return BitConverter.ToString(HashedArray).Replace("-", "");
        }
        public string Name
        {
            get
            {
                return "SHA1";
            }
        }
        #endregion
    }
}
